//
//  HNHistoryHeaderTableViewCell.m
//  HappyNews
//
//  Created by lanou on 16/1/17.
//  Copyright © 2016年 BPWBANP. All rights reserved.
//

#import "HNHistoryHeaderTableViewCell.h"

@implementation HNHistoryHeaderTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        _imageA = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, kScreenWidth / 2.5, kScreenHeight / 7.8)];
        // _imageV.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_imageA];
        
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(_imageA.right + 10, _imageA.top,kScreenWidth - _imageA.width - 30 , _imageA.height / 1.5)];
        _titleLabel.text = @"哈哈啊哈哈哈哈哈啊哈哈哈哈哈哈哈";
        _titleLabel.numberOfLines = -1;
        [_titleLabel sizeToFit];
        //_titleLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_titleLabel];
        
        _durationImage = [[UIImageView alloc]initWithFrame:CGRectMake(_titleLabel.left, _imageA.bottom - 25, 20, 20)];
        // _durationImage.backgroundColor = [UIColor redColor];
        _durationImage.image = [UIImage imageNamed:@"iconfont-shijian"];
        [self.contentView addSubview:_durationImage];
        
        _durationLabel = [[UILabel alloc]initWithFrame:CGRectMake(_durationImage.right + 5, _durationImage.top, 60, 20)];
        //_durationLabel.backgroundColor = [UIColor redColor];
        _durationLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:_durationLabel];
        
        
        _playTimeImage = [[UIImageView alloc]initWithFrame:CGRectMake(_durationLabel.right - 10, _durationLabel.top, _durationImage.width, _durationImage.height)];
        _playTimeImage.image = [UIImage imageNamed:@"iconfont-bofang"];
        // _playTimeImage.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_playTimeImage];
        
        
        _playTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(_playTimeImage.right + 5, _playTimeImage.top, _durationLabel.width + 5, _durationLabel.height)];
        _playTimeLabel.textColor = [UIColor grayColor];
        // _playTimeLabel.backgroundColor = [UIColor redColor];
        [self.contentView addSubview:_playTimeLabel];
        
        
        
    }
    return self;
}

- (void)setModel:(HNChoicenessModel *)model
{
    _model = model;
    
    [_imageA sd_setImageWithURL:[NSURL URLWithString:model.imageV] placeholderImage:nil];
    
    
    _titleLabel.text = model.name;
    
    
    
    NSInteger a = [model.duration intValue];
    NSString *string = [NSString stringWithFormat:@"%02ld:%02ld",a/60,a%60];
    _durationLabel.text = string;
    
    
    if (model.playTime.length >= 5) {
        CGFloat b = [model.playTime intValue];
        NSString *str = [NSString stringWithFormat:@"%.1f万",b/10000];
        _playTimeLabel.text = str;
    }else{
        _playTimeLabel.text = model.playTime;
    }
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
